package homework4CalculateArea;

import java.util.ArrayList;
import java.util.Scanner;

public class Demo{
	public static void main(String[] args) {
		ArrayList<Shape> shapeList = new ArrayList<Shape>();
		Scanner scanner = new Scanner(System.in);
		int input;
		do {
			double sideLong = 0;
			double sideShort = 0;
			System.out.println("1.添加圆形 2. 添加矩形 3.三角形 4.计算所有面积 5. 退出");
			input = scanner.nextInt();
			switch (input) {
			case 1:
				System.out.print("请输入半径:");
				sideLong = scanner.nextDouble();
				Shape circle = new Circle(sideLong);
				shapeList.add(circle);
				break;
			case 2:
				System.out.print("请输入长和宽:");
				sideLong = scanner.nextDouble();
				sideShort = scanner.nextDouble();
				Shape Rectangle = new Rectangle(sideLong, sideShort);
				shapeList.add(Rectangle);
				break;
			case 3:
				System.out.print("请输入底和高:");
				sideLong = scanner.nextDouble();
				sideShort = scanner.nextDouble();
				Shape Triangle = new Triangle(sideLong, sideShort);
				shapeList.add(Triangle);
				break;
			case 4:
				for(int i = 0; i < shapeList.size();i++){
					System.out.printf("%s的面积为：%f。\n",shapeList.get(i).name,shapeList.get(i).area);
				}
				break;
			default:
				break;
			}
		} while (input != 5);
	}
}